package ma30082014;

import java.io.BufferedReader;
import java.io.InputStreamReader;
//reverse sentence, words are separated by space
public class Solution1 {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		while(t-- > 0) {
			String str = br.readLine();
			String[] splitted = str.split(" ");
			StringBuilder rev = new StringBuilder();
			for (int i = splitted.length - 1; i >= 0; i--) {
				rev.append(splitted[i]).append(" ");
			}
			System.out.println(rev.toString());
		}
	}

}
